<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <title>Document</title>
    <script>
        function spaOperation() {
            let hash = window.location.hash.replace("#", "");
            console.log(hash);
            if (hash == "userManager") {
                let xhr = new XMLHttpRequest();
                xhr.open("get", "../views/userManager.html", true);
                xhr.addEventListener("readystatechange", () => {
                    document.getElementById("insertPoint").innerHTML = xhr.responseText;
                }, false);
                xhr.send(null);
            }
            if (hash == "mainPage") {
                let xhr = new XMLHttpRequest();
                xhr.open("get", "../demo/mainpage.html", true);
                xhr.addEventListener("readystatechange", () => {
                    document.getElementById("insertPoint").innerHTML = xhr.responseText;
                }, false);
                xhr.send(null);
            }
        }
        window.addEventListener("hashchange", spaOperation, false);
    </script>
</head>

<body>
    <a href="#mainPage">主页</a>
    <a href="#userManager">用户信息管理</a>
    <hr>
    <div id="insertPoint"></div>
</body>

</html>